package com.banach.prema.repository;

import com.banach.prema.repository.dataobject.GroupDO;
import com.banach.prema.repository.mapper.GroupMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ego.framework.jdbc.repository.BaseRepository;
import org.springframework.stereotype.Component;

@Component
public class GroupRepository extends BaseRepository<GroupMapper, GroupDO, GroupDO> {
    public GroupDO selectByOwnerAndCode(String ownerAccount,String code){
        LambdaQueryWrapper<GroupDO> queryWrapper = Wrappers.<GroupDO>lambdaQuery()
                .eq(GroupDO::getOwnerAccount, ownerAccount)
                .eq(GroupDO::getCode, code)
                .eq(GroupDO::getValid, true);
        return this.baseMapper.selectOne(queryWrapper);
    }
}
